<?php
header("Content-type:text/html;charset=utf-8");
define("DEBUG", true);
if (DEBUG)
{
	ini_set('display_errors', 'On');
	error_reporting( E_ALL );
}

//设置时区
date_default_timezone_set('Etc/GMT-8');

define("LOGIN_TIME_LIMIT", 18000); //登录超时时间
define("APP_NAME", 'lejuhui');
define("ROOT_DIR", $_SERVER['DOCUMENT_ROOT'].'/');

define("ICL_DIR", ROOT_DIR . 'include/');
define("LIB_DIR", ROOT_DIR . 'library/');
define("ACT_DIR", ROOT_DIR . "action/");
define("DB_DIR", ROOT_DIR . "data/");

define("API_PRIVATE_KEY",'o#0q5p3s8d8j3%w7');
define('PRIVATEKEY','i3k2q9!4$sw1e45v7x#8p2&aq@f1z3%t');

define("CTRL_DIR", ROOT_DIR . "controller/");
define("MOD_DIR", ROOT_DIR . "module/");
define('TEMPLATE_DIR', ROOT_DIR . 'templates/'); //模板目录
define('VIEW_COMPILE_DIR', $_SERVER['SINASRV_CACHE_DIR'] . "_templates_c"); //smarty 编译目录
define('VIEW_CACHE_DIR', $_SERVER['SINASRV_CACHE_DIR'] . "_templates_cache");//smarty 缓存目录

//登录
define('SALES_KEY','0o9i8u7y');
define("USERSURL", "http://admin.websales.com/");
//swfupload
define('SWF_KEY','^%$0RT!~');

//added by yangwenfeng
//保证金支付状态
//define('PAY_STATUS_NO',               0);//未付款
//define('PAY_STATUS_PAYED',            1);//已付款
//define('PAY_STATUS_REFUND',           2);//已退款

//$include_path = ini_get( 'include_path' );
//ini_set('include_path', $include_path.":".ICL_DIR."PHPExcel");

//mingyu@leju.sina.com.cn  增加 ESALES_LEJU
$dev = strpos($_SERVER['HTTP_HOST'], 'dev');
$bch = strpos($_SERVER['HTTP_HOST'], 'bch');

$base_domain = "eju.com";
$site_url = "";


if($dev === false && $bch === false)
{
	//define('API_URL', 'http://i.api.' . $base_domain . "/");
	//define('ILEJU_URL', 'http://i.' . $base_domain . "/");
    $site_url = $base_domain === "eju.com" ? "http://www.eju.com" : "http://esales.leju.com";
	define('ESALES_LEJU', $site_url);
}
else
{
    if ($dev !== false)
    {
        //define('API_URL', 'http://i.api.dev.' . $base_domain . "/");
        //define('ILEJU_URL', 'http://i.dev.' . $base_domain . "/");
        define('ESALES_LEJU', 'http://www.dev.eju.com/');
    }
    if ($bch !== false)
    {
        //define('API_URL', 'http://i.api.bch.' . $base_domain . "/");
        //define('ILEJU_URL', 'http://i.bch.' . $base_domain . "/");
        $site_url = $base_domain === "eju.com" ? "http://www.bch.eju.com" : "http://esales.bch.leju.com";
        define('ESALES_LEJU', $site_url);
    }

}


//自动加载规则
function __autoload($classname)
{
	$path = explode('_',$classname);

	switch ($path[0]) {
		case 'module'://加载模块类
			$classname = str_replace('module_', '', $classname);
			$classname = str_replace('_', '/', $classname);
			$file = MOD_DIR . $classname . '.class.php';
			break;
		case 'controller'://加载控制器类
			$classname = str_replace('controller_', '', $classname);
			$classname = str_replace('_', '/', $classname);
			$file  = CTRL_DIR . $classname . '.class.php';
			break;
		case 'lib'://加载library
			$classname = str_replace('lib_', '', $classname);
			if($path[1]=='base')
			$file  = LIB_DIR .'base/'.$path[2] . '.class.php';
			else
			{
			    $classname = str_replace('_', '/', $classname);
			    $file  = LIB_DIR .$classname. '.class.php';
			}
			break;
		case 'data'://加载data
			$classname = str_replace('data_', '', $classname);
			$classname = str_replace('_', '/', $classname);
			$file  = DB_DIR . $classname . '.class.php';
			break;
        case 'PHPExcel'://excel导入用
            $classname = str_replace('_', '/', $classname);
            $file  = ICL_DIR . $classname . '.php';
            break;
        case 'wsclient'://sdk
            $classname = str_replace('_', '/', $classname);
            $file  = ICL_DIR . $classname . '.class.php';
            break;
	}

	if (isset($file) && file_exists($file))
	{
		require_once "$file";
	}
	else
	{
		if (!class_exists($classname, false)) {
	        return false;
	    }

		require_once 'library/base/exception.class.php';
		throw new lib_base_exception($file_name.'');
	}


}

//view_config
$__view__ = array(
	'caching' => 0, //0 = no cache; 1 = use class cache_lifetime value; 2 = use cache_lifetime in cache file
);
//db config
$__db__ = array(	
	0 => array(
		'user' => $_SERVER['SINASRV_DB_USER'],
		'password' => $_SERVER['SINASRV_DB_PASS'],
		'host' => $_SERVER['SINASRV_DB_HOST'],
		'port' => $_SERVER['SINASRV_DB_PORT'],
		'database' => $_SERVER['SINASRV_DB_NAME']
	),

	1 => array(
		'user' => $_SERVER['SINASRV_DB_USER_R'],
		'password' => $_SERVER['SINASRV_DB_PASS_R'],
		'host' => $_SERVER['SINASRV_DB_HOST_R'],
		'port' => $_SERVER['SINASRV_DB_PORT_R'],
		'database' => $_SERVER['SINASRV_DB_NAME_R']
	)

);

$email_config['mail_host']	= 'mail.renxun.net';		// SMTP 服务器  
$email_config['send_user']	= 'admin@renxun.net';		// 用户名 
$email_config['send_pass']	= 'qwe123';					// 密码
$email_config['fromName']	= 'admin';					// 发信人别名
$email_config['frommail']	= 'admin@renxun.net';		// 发信人 

//房源配置
/*
$__house__ = array(
                    'sale_style' => module_fy_house::get_sale_style(),
                    'status' => module_fy_house::get_status(),
                    'edit_status' => module_fy_house::get_status(true),
                );

$__building__ = array(
                    'rentsale_type' => module_fy_building::get_rentsale_type(),
                    'building_type' => module_fy_building::get_building_type()
                );

$__project__ = array(
                        'status' => module_fy_project::get_status(),
                        'property_type' => module_fy_project::get_property_type(),
                        'structure' => module_fy_project::get_structure(),
                        'wuye_type' => module_fy_project::get_wuye_type(),
                        'new_wuye_type' => module_fy_project::get_new_wuye_type(),
                        'fitment_type' => module_fy_project::get_fitment_type(),
                        'electric_condition' => module_fy_project::get_electric_condition()
                    );
$__housetype__ = array ( 'type' => module_fy_housetype::get_type() );

$__user__ = array( 'status' => array( 1=> '使用中', 2 => '已暂停', 3=> '已关闭' ) );
$__partner__ = array( 'status' => module_partner::get_status() );

$__order__ = array(
				'status' => array(0=>'无效', 1=>'有效'),
				'pay_status' => array(0=>'未支付', 1=>'支付成功等待卖家确认', 2=>'卖家确认等待买家确认', 3=>'交易成功', 4=>'交易中途关闭等失败信息'),
				'refund_status' => array(0=>'未申请退款', 1=>'退款协议等待卖家确认中', 2=>'卖家不同意', 3=>'退款协议达成等待买家退货', 4=>'等待卖家收货', 5=>'退款成功', 6=>'退款关闭')
			);
$__frontpageuser__ = array(0=>"正常", 1=>"禁止登录");

//1M限制房源文件上传最大容量(bytes)
$house_file_size = 1000*1000;

$rule_type = array(1=>'英国式竞购（明标）',2=>'荷兰式竞购',3=>'英国式竞购（暗标）',4=>'阶梯式团购（适用于多套房源网上销售）');

$unit_type = array('元/平方米','元/套','美元/月·平方米','元/月·平方米',);
$api_url = 'http://api.superwebsales.com/payment/';

//活动类型
$_activity_type = array(
	1 => '项目专卖',
	2 => '竞卖区',
	3 => '团购区',
	4 => '旅游地产',
	5 => '二手房',
);

//退款审核
$_refund_status = array(
	0 => '未处理',
	1 => '已确认',
	2 => '退款中',
	3 => '退款完成等待确认',
	4 => '用户确认退款完成',
);
*/